Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

horizon/ingest: support parsing of new InvokeHostFunction op #4608

Merged

Conversation

sreuland
Copy link
Contributor

@sreuland sreuland commented Sep 23, 2022

PR Checklist

PR Structure

  • This PR has reasonably narrow scope (if not, break it down into smaller PRs).
  • This PR avoids mixing refactoring changes with feature changes (split into two PRs
    otherwise).
  • This PR's title starts with name of package that is most changed in the PR, ex.
    services/friendbot, or all or doc if the changes are broad or impact many
    packages.

Thoroughness

  • This PR adds tests for the most critical parts of the new functionality or fixes.
  • I've updated any docs (developer docs, .md
    files, etc... affected by this change). Take a look in the docs folder for a given service,
    like this one.

Release planning

  • I've updated the relevant CHANGELOG (here for Horizon) if
    needed with deprecations, added features, breaking changes, and DB schema changes.
  • I've decided if this PR requires a new major/minor version according to
    semver, or if it's mainly a patch change. The PR is targeted at the next
    release branch if it's not a patch change.

What

Adding support in ingest and on api resource model for new InvokeHostFunction operation.
Adding test coverage on tx submit for InvokeHostFunction.

Why

Closes #4604

Known limitations

@tsachiherman tsachiherman linked an issue Sep 26, 2022 that may be closed by this pull request
@tamirms tamirms force-pushed the 4604_invokehostfunction_support branch from 54df7f6 to 940db2e Compare September 28, 2022 18:29
@sreuland sreuland marked this pull request as ready for review September 28, 2022 22:32
func submitInvokeHostFunction(itest *integration.Test, tt *assert.Assertions) (submittedOperations []txnbuild.Operation, lastLedger int32) {
ops := []txnbuild.Operation{
&txnbuild.InvokeHostFunction{
Function: xdr.HostFunctionHostFnCall,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these values be populated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this test coverage, success/fail of tx was not scope for assertion, rather, it's just the presence of the InvokeHostFunction xdr going through ingest, so tried to avoid further complexity on that.

if raw, err := param.MarshalBinary(); err == nil {
serializedParam["value"] = base64.StdEncoding.EncodeToString(raw)
}
params = append(params, serializedParam)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any case where we want to add a serializedParam here that doesn't have a value ?
i.e. that's what going to happen in case MarshalBinary would return an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there shouldn't be based on type safety of the gen'd xdr structs, but rather than ignore the runtime serialization error
in any case, I've done some conservative err handling and test coverage of that exceptional case of a malformed param - 68a1d74

Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few small comments, but looks good otherwise!

@sreuland sreuland merged commit 6bb9139 into stellar:soroban-xdr-next Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

horizon: support soroban InvokeHostFn xdr parsing
5 participants